<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import =  "org.apache.commons.beanutils.PropertyUtils,
                    com.broadvision.web.util.ViewDynaBean,
                    java.util.List"
%>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language="JavaScript">

//
function closeWindow() {
  self.close();
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

//
function setCategoryName(theForm) {

  var catName = trim(theForm.categoryName.value);
  theForm.categoryName.value = catName;

  if (theForm.categoryName.value == "") {
    alert('<bean-el:message bundle="cm.messages" key="error.browse.emptyCategoryName"/>');
  }
  else {
    if (window != null && window.opener != null) {
      window.opener.setCategoryName(theForm.parentFormName.value, theForm.cntTypeId.value,
        theForm.currentCategoryOid.value, theForm.subcategoryOid.value, 
        theForm.categoryName.value);
      window.close();
    }
  }
}

</script>

<html-el:form action="/cm/editCategoryPopup.do" 
  onsubmit="setCategoryName(cmCntCategoryEditPopupForm); return false;" 
  focus="categoryName">
  <html-el:hidden name="cmCntCategoryEditPopupForm" property="parentFormName"/>
  <html-el:hidden name="cmCntCategoryEditPopupForm" property="cntTypeId"/>
  <html-el:hidden name="cmCntCategoryEditPopupForm" property="currentCategoryOid"/>
  <html-el:hidden name="cmCntCategoryEditPopupForm" property="subcategoryOid"/>
  <!-- Zone 5 starts here.  -->
  <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
    <tr>
      <td valign="top" width="100%">
        <div class="generalWrapRight">
          <html-el:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
            <bean-el:message bundle="cm.messages" key="button.close"/>
          </html-el:button>
        </div> 
        <div class="pageSubtitle">
          <c:choose>
          <c:when test="${cmCntCategoryEditPopupForm.map.subcategoryOid == 0}">
            <bean-el:message bundle="cm.messages" key="cm.browse.create.title"/>
          </c:when>
          <c:otherwise>
            <bean-el:message bundle="cm.messages" key="cm.browse.rename.title"/>
          </c:otherwise>
          </c:choose>
          <span class="right">&nbsp;</span>
        </div>
        <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Process summary">
          <tr> 
            <td class="label"><bean-el:message bundle="cm.messages" key="cm.browse.category.name"/>:*</td>
            <td class="labelField">
              <html-el:text name="cmCntCategoryEditPopupForm" property="categoryName" size="20"/>
            </td>
          </tr>
        </table>
        <div class="pageButtonWrap" align="right">
          <input type="button" name="cancelData" class="pageButton" 
            onClick="javascript:closeWindow()" 
            value='<bean-el:message bundle="cm.messages" key="button.cancel"/>'/>
          <c:choose>
          <c:when test="${cmCntCategoryEditPopupForm.map.subcategoryOid == 0}">            
            <input type="submit" name="createCategory" class="pageButton" 
              value='<bean-el:message bundle="cm.messages" key="button.create"/>'/>
          </c:when>
          <c:otherwise>                
            <input type="submit" name="renameCategory" class="pageButton" 
              value='<bean-el:message bundle="cm.messages" key="button.rename"/>'/>
          </c:otherwise>
          </c:choose>
        </div>
      </td>
    </tr>
  </table>
  <!--end zone 5 content here -->
</html-el:form>

